<table class="table" id="somainDiv">
    <thead>
    <tr>
        <th>序号</th>
        <th>销售单编号</th>
        <th>创建时间</th>
        <th>客户名称</th>
        <th>创建用户</th>
        <th>附加费用</th>
        <th>销售商品总价</th>
        <th>销售单总价</th>
        <th>付款方式</th>
        <th>最低预付款金额</th>
        <th colspan="2">操作</th>
    </tr>
    </thead>
    <tbody id="tableBody"></tbody>
</table>
<div>
    <ul id="page">分页</ul>
</div>

<script id="outStoreListTemplate" type="text/html">
    {{each data value index}}
    <tr>
        <td>{{index+1}}</td>
        <td>{{value.soId}}</td>
        <td>{{value.createTime}}</td>
        <td>{{value.customerList[0].name}}</td>
        <td>{{value.scmUserList[0].name}}</td>
        <td>{{value.tipFee}}</td>
        <td>{{value.productTotal}}</td>
        <td>{{value.soTotal}}</td>
        <td>{{value.payType}}</td>
        <td>{{value.prePayFee}}</td>
        <td><input value="出库" type="button"  onclick="outStore('{{value.soId}}')"></td>
        <td><input value="查看明细" type="button"  onclick="soitem('{{value.soId}}')"></td>
    </tr>
    {{/each}}
</script>

<script>
    $(function () {
        showPage({
            currentPage: 1,
            pageSize: 5,
            url: '/getAllSomainInStore',
            templateId: 'outStoreListTemplate',
            contentId: 'tableBody',
            params: {
                id: 1
            }
        })
    })
    function outStore(obj) {
        Date.prototype.Format = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1, // 月份
                "d+": this.getDate(), // 日
                "h+": this.getHours(), // 小时
                "m+": this.getMinutes(), // 分
                "s+": this.getSeconds(), // 秒
                "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
                "S": this.getMilliseconds() // 毫秒
            };
            if (/(y+)/.test(fmt))
                fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }
        var orderCode = new Date().Format("yyyyMMddhhmmss");
        var stockTime=new Date().Format("yyyy-MM-dd hh:mm:ss");
        Ajax.post(
            "/updateSoMainOutStore",
            {
                soId:obj,
                orderCode:obj,
                stockTime:stockTime,
                createUser:window.sessionStorage.getItem("name")},
            function (result) {
                show('store/outStore.html')
                alert(result.msg)
            }
        )
    }
    function soitem(obj) {
        window.sessionStorage.setItem("soId",obj)
        show("/store/outStoreSomain.html")
    }
</script>
